#ifndef SOCKS_H_
#define SOCKS_H_

#include <netinet/in.h>
#include <ev.h>

enum socks_ver {
    SOCKS4 = 4,
    SOCKS5 = 5,
};

struct socks4 {
    unsigned char vn;
    unsigned char cd;
    in_port_t port;
    in_addr_t ip;
    unsigned char uid[0];
};

struct socks5 {
    unsigned char ver;
    union {
        unsigned char cmd;
        unsigned char rep;
    };
    unsigned char rsv;
    unsigned char atyp;
    union {
        unsigned char addr[256 + 2];
        struct {
            struct in_addr addr;
            in_port_t port;
        } in4;
        struct {
            struct in6_addr addr;
            in_port_t port;
        } in6;
        struct {
            unsigned char len;
            char domain[255];
            /* in_port_t port; */
        } domain;
    };
};

/* socks request info */
struct socks {
    const char *s4a_domain;
};

void socks4_addr_handler(EV_P_ ev_io *w, int revents);
void socks5_hello_handler(EV_P_ ev_io *w, int revents);

#endif /* SOCKS_H_ */
